﻿@{
    Layout = "~/Views/Shared/_Layout.cshtml";
    ViewData["Title"] = "湖北省检察院档案管理系统 - 个人 -我的诉讼档案";
}
<style type="text/css">
    .Lawsuit-tool-content {
        margin-top: -5px;
    }
</style>

<div class="Lawsuit-body">
    <div class="layui-form Lawsuit-form search">
        <div class="layui-inline">
            <select class="layui-select" id="FileState" name="FileState">
                <option value="">全部</option>
                <option value="0">未提交</option>
                <option selected="selected" value="1">待审核</option>
                <option value="2">通过</option>
                <option value="-1">不通过</option>
            </select>
        </div>
        <div class="layui-inline">
            <select class="layui-select" id="FileClass" name="FileClass">
                <option value="">案卷类别</option>
                <option value="民事行政">民事行政</option>
                <option value="公益诉讼">公益诉讼</option>
                <option value="刑事诉讼">刑事诉讼</option>
            </select>
        </div>
        <div class="layui-inline">
            <input type="text" id="FileNo" name="FileNo" placeholder="档号" class="layui-input" />
        </div>
        <div class="layui-inline">
            <input type="text" id="FYear" name="FYear" class="layui-input" placeholder="开始年度-结束年度" />
        </div>
        <div class="layui-inline">
            <select class="layui-select" id="FTerm" name="FTerm">
                <option selected="selected" value="">-- 期限 --</option>
                <option value="1">永久</option>
                <option value="2">长期</option>
                <option value="3">短期</option>
            </select>
        </div>
        <div class="layui-inline">
            <input type="text" id="CaseValue" name="CaseValue" class="layui-input" placeholder="案由" />
        </div>
        <div class="layui-inline">
            <input type="text" id="DSR" name="DSR" class="layui-input" placeholder="当事人" />
        </div>
        <div class="layui-inline">
            <input type="button" title="检索" class="layui-btn layui-btn-sm reload"  value="检索" />
        </div>
    </div>
    <table class="layui-hide" id="table1" lay-filter="table1"></table>
</div>

<script type="text/html" id="toolbar1">
    <div class="Lawsuit-tool-content">
        <div class="layui-btn-container Lawsuit-btn-container">
            <button type="button" class="layui-btn layui-btn-sm" lay-event="add">建立档案</button>
            <button type="button" class="layui-btn layui-btn-sm" lay-event="update">修改档案</button>
            <button type="button" class="layui-btn layui-btn-sm layui-btn-danger" lay-event="delete">删除档案</button>
            <button type="button" class="layui-btn layui-btn-sm" lay-event="Directory">目录编写</button>
            <button type="button" class="layui-btn layui-btn-sm" lay-event="DirectoryPost">目录提交审核</button>
            <div class="layui-inline" style="display:none">
                <blockquote class="layui-elem-quote layui-quote-nm Lawsuit-elem-quote">
                    (封面录入→目录录入→提交审核→审核通过→打印封面、目录→图像采集→采集完成→提交审核→审核通过→打印移交清单→生成移交信息)
                </blockquote>
            </div>
        </div>
    </div>
</script>

@section scripts{
    <script>
        layui.config({
            base: '/layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'table', 'jquery', 'laydate', 'layer', 'form'], function () {
            var form = layui.form, table = layui.table, $ = layui.$, index = layui.index, laydate = layui.laydate, layer = layui.layer;
            //单击行勾选checkbox事件
            $(document).on("click", ".layui-table-body table.layui-table tbody tr", function () {
                /*当单击表格行时,把单选按钮设为选中状态*/
                var tableDiv;
                var index = $(this).attr('data-index');
                var tableBox = $(this).parents('.layui-table-box');
                //存在固定列
                if (tableBox.find(".layui-table-fixed.layui-table-fixed-l").length > 0) {
                    tableDiv = tableBox.find(".layui-table-fixed.layui-table-fixed-l");
                } else {
                    tableDiv = tableBox.find(".layui-table-body.layui-table-main");
                }
                var checkCell = tableDiv.find("tr[data-index=" + index + "]").find("td div.laytable-cell-checkbox div.layui-form-checkbox I");
                if (checkCell.length > 0) {
                    checkCell.click();
                }
            });

            //对td的单击事件进行拦截停止，防止事件冒泡再次触发上述的单击事件
            $(document).on("click", "td div.laytable-cell-checkbox div.layui-form-checkbox", function (e) {
                e.stopPropagation();
            });

            laydate.render({
                elem: "#FYear"
                , type: 'year'
                , range: true
            });

            var talbe1 = table.render({
                elem: '#table1',
                url: "/Personal/SuSong/GetAllPersonalSuSongJson",
                toolbar: '#toolbar1',
                // defaultToolbar: ['filter','print','exports'],
                defaultToolbar: ['filter'],
                size: 'sm',
                height: 'full-60',
                cellMinWidth: '100',
                page: true,
                id: 'table1Reload',
                sort: true, 
                height: 460,
                cols: [[
                    { field: 'xh', type: 'checkbox', LAY_CHECKED: false, fixed: 'left' }
                    , { field: 'filesState', title: '审核状态', align: 'center', sort: true,fixed: 'left' }
                    , { field: 'fileNo', title: '临时档号', sort: true }
                    , { field: 'fType', title: '案件类别', align: 'center', width: 100, sort: true }
                    , { field: 'fYear', title: '年度', align: 'center', width: 70, sort: true }
                    , { field: 'fTerm', title: '期限', align: 'center', width: 70, sort: true }
                    , { field: 'bookType', title: '册类型', align: 'center', width: 70 }
                    , { field: 'dept', title: '部门' }
                    , { field: 'litigant', title: '当事人' }
                    , { field: 'ssr', title: '申诉人' }
                    , { field: 'bssr', title: '被申诉人' }
                    , { field: 'fzxyrbgr', title: '犯罪嫌疑人/被告人' }
                    , { field: 'sqr', title: '申请人' }
                    , { field: 'otherLitigant', title: '其他当事人' }
                    , { field: 'unDepart', title: '终审法院' }
                    , { field: 'undertaker', title: '承办人' }
                    , { field: 'danWei', title: '主办单位' }
                    , { field: 'receiveDate', title: '收案日期', width: 100, align: 'center', sort: true }
                    , { field: 'endDate', title: '结案日期', width: 100, align: 'center', sort: true }
                    , { field: 'result1', title: '处理结果' }
                    , { field: 'result2', title: '办理结果' }
                    , { field: 'filingDate', title: '归档日期', width: 100, align: 'center', sort: true }
                    , { field: 'pageCount', title: '页数', width: 70, align: 'center', sort: true }
                    , { field: 'secure', title: '密级', align: 'center', sort: true }
                ]],
                text: "对不起，加载出现异常！",
                done: function (res, curr, count) {
                    if (res.count == 0) {
                        $(".layui-table-main").html('<div class="layui-none">暂无数据</div>');
                    }

                    $("[data-field='filesState']").children().each(function () {
                        if ($(this).text() == '0') {
                            $(this).html("<span class='layui-badge layui-bg-gray'>待提交</span>")
                        } else if ($(this).text() == '1') {
                            $(this).html("<span class='layui-badge layui-bg-blue'>待审核</span>")
                        } else if ($(this).text() == '2') {
                            $(this).html("<span class='layui-badge layui-bg-green'>通过</span>")
                        } else if ($(this).text() == '-1') {
                            $(this).html("<span class='layui-badge layui-bg-red'>不通过</span>")
                        }
                    });
                }
            });

            table.on('sort(table1)', function (obj) { //注：sort 是工具条事件名，table1 是 table 原始容器的属性 lay-filter="对应的值"
                table.reload('table1Reload', {
                    initSort: obj,//记录初始排序，如果不设的话，将无法标记表头的排序状态。 layui 2.1.1 新增参数
                    where: { //请求参数（注意：这里面的参数可任意定义，并非下面固定的格式）
                        field: obj.field //排序字段   在接口作为参数字段  field order
                        , order: obj.type //排序方式   在接口作为参数字段  field order
                    }
                });

            });

            table.on('toolbar(table1)', function (obj) {
                var checkStatus = table.checkStatus('table1Reload');
                switch (obj.event) {
                    case 'add':
                        top.layer.open({
                            type: 2,
                            title: '诉讼档案建档'
                            , content: '/Personal/SuSong/LawsuitForm?type=add'
                            , skin: 'demo-class'
                            , maxmin: true
                            , area: ['800px', '600px']
                            , btn: ['保存', '关闭']
                            , yes: function (index, layero) {
                                //点击确认触发 iframe 内容中的按钮提交
                                var submit = layero.find('iframe').contents().find("#layuiadmin-app-form-submit");
                                submit.click();
                            }
                            , end: function (index) {
                                table.reload('table1Reload'); //重载表格
                                layer.close(index); //再执行关闭
                            },
                            zIndex: layer.zIndex, //重点1
                            success: function (layero) {
                                layer.setTop(layero); //重点2
                            }
                        })
                        break;
                    case 'update':
                        var checkStatusa = table.checkStatus('table1Reload'),
                            checkData = checkStatusa.data; //得到选中的数据
                        if (checkData.length < 1) {
                            return layer.msg('请选择数据', { icon: 7 });
                        }
                        else if (checkData.length === 1) {
                            top.layer.open({
                                type: 2,
                                title: '诉讼档案修改'
                                , content: '/Personal/SuSong/LawsuitForm?type=edit&id=' + checkData[0].id
                                , area: ['800px', '600px']
                                , btn: ['保存', '关闭']
                                , yes: function (index, layero) {
                                    //点击确认触发 iframe 内容中的按钮提交
                                    var submit = layero.find('iframe').contents().find("#layuiadmin-app-form-edit");
                                    submit.click();
                                }
                                , end: function (index) {
                                    table.reload('table1Reload'); //重载表格
                                    layer.close(index); //再执行关闭
                                },
                                zIndex: layer.zIndex, //重点1
                                success: function (layero) {
                                    //layer.setTop(layero); //重点2
                                },
                                btn2: function (index, layero) {

                                }
                            })
                        }
                        else {
                            return layer.msg('不能多选', { icon: 7 });
                        }
                        break;
                    case 'delete':
                        var checkStatusa = table.checkStatus('table1Reload'),
                            checkData = checkStatusa.data; //得到选中的数据
                        if (checkData.length === 0) {
                            return layer.msg('请选择数据！', { icon: 7 });
                        } else {
                            var ids = "";
                            for (var i = 0; i < checkData.length; i++) {
                                if (i == 0) {
                                    ids = checkData[i].id;
                                } else {
                                    ids = ids + "," + checkData[i].id;
                                }
                            }
                            layer.confirm('确定删除吗？', function (index) {
                                $.post({
                                    url: "/Personal/SuSong/del?ids=" + ids
                                    , success: function () {
                                        layer.close(index);
                                        table.reload('table1Reload');
                                        layer.msg('已删除 ！', { icon: 1 });
                                    }
                                });
                            });
                        }
                        break;
                    case 'Directory'://目录编写
                        var checkStatusa = table.checkStatus('table1Reload'),
                            checkData = checkStatusa.data; //得到选中的数据
                        if (checkData.length === 0) {
                            return layer.msg('请选择数据！', { icon: 7 });
                        } else if (checkData.length === 1) {
                            parent.layer.open({
                                shade: [0.5, '#000', false],
                                type: 2,
                                title: '诉讼档案卷内目录'
                                , content: ['/Personal/SuSong/Directory?id=' + checkData[0].id, 'no']//防止滚动条
                                , area: ['1000px', '600px']
                                , btn: ['保存', '关闭']
                                , yes: function (index, layero) {
                                    //点击确认触发 iframe 内容中的按钮提交
                                    var submit = layero.find('iframe').contents().find("#layuiadmin-app-form-submit");
                                    submit.click();
                                },
                                btn2: function (index, layero) {

                                }
                            });
                        } else {
                            return layer.msg('不能多选！', { icon: 7 });
                        }
                        break;
                    case 'DirectoryPost':
                        if (checkStatus.data.length === 0) {
                            return layer.msg('请选择数据！', { icon: 3 });
                        } else {
                            return layer.msg('功能开发中！', { icon: 5 });
                            //return layer.confirm("确定要提交选中的这些档案给管理员审核？", { icon: 3, title: '提示', btn: ['确定', '取消'] })
                        }
                        break;
                };
            })

            $('.reload').on('click', function () {
                var fileState = $("#FileState").val();
                var fileClass = $("#FileClass").val();
                var fileNo = $("#FileNo").val();
                var fYear = $("#FYear").val();
                var fTerm = $("#FTerm").val();
                var caseValue = $("#CaseValue").val();
                var dsr = $("#DSR").val();

                //执行重载
                table.reload('table1Reload', {
                    url: "/Personal/SuSong/GetAllPersonalSuSongJson",
                    page: { curr: 1 },
                    where: {
                        fileState: fileState,
                        fileClass: fileClass,
                        fileNo: fileNo,
                        fYear: fYear,
                        fTerm: fTerm,
                        caseValue: caseValue,
                        dsr: dsr
                    }
                }, 'data');
            });
        })
    </script>
}